package com.deluxelx.rmo.common.constants;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class IllegalWords {

    private static final IllegalWords instance = new IllegalWords();

    // 初始化敏感词列表
    private static final List<String> illegalWords = new ArrayList<>();
    static {
        try {
            ClassLoader classLoader = ClassLoader.getSystemClassLoader();
            InputStream in = classLoader.getResourceAsStream("sensitive_words.txt");
            InputStreamReader inputStreamReader = new InputStreamReader(Objects.requireNonNull(in));
            BufferedReader reader = new BufferedReader(inputStreamReader);
            String line;
            while ((line = reader.readLine()) != null) {
                illegalWords.add(line);
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private IllegalWords() {}

    public static IllegalWords getInstance() {
        return instance;
    }

    public List<String> getIllegalWords() {
        return illegalWords;
    }

}
